<template>
    <div class="container">

        <div class="container">
            <div class="circle" :class="{ 'active': isActive }" @click="toggleCircle">
                <span v-if="isActive" class="checkmark">✔️</span>
            </div>
        </div>

        <div class="square">
            <el-radio-group v-model="selectedItems" @change="handleSelect">
                <div v-for="item in items" :key="item.id" class="item-container">
                    <el-radio :label="item.id" class="radio">
                        <span :class="{ 'strikethrough': item.completed, 'completed-text': item.completed }">
                            {{ item.content }}
                        </span>
                    </el-radio>
                </div>
            </el-radio-group>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue';

// 模拟数据
const items = ref([
    { id: 1, content: '任务 1:记得明天早上要早餐', completed: false },
    { id: 2, content: '任务 2', completed: false },
    { id: 3, content: '任务 3', completed: false },
    { id: 4, content: '任务 4', completed: false },
]);

const selectedItems = ref([]);

const handleSelect = (value) => {
    const selectedItem = items.value.find(item => item.id === value);
    if (selectedItem) {
        selectedItem.completed = !selectedItem.completed; // 切换完成状态
    }
};




// 使用响应式变量来管理状态
const isActive = ref(false);
// 切换圆圈状态
const toggleCircle = () => {
  isActive.value = !isActive.value;
};
</script>

<style>
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.square {
    width: 300px;
    border: 2px solid #dcdfe6;
    border-radius: 8px;
    padding: 10px;
    overflow-y: auto;
}

.item-container {
    margin: 5px 0;
    /* 每个任务之间的间隔 */
}

.radio {
    width: 240px;
    background-color: rgb(218, 218, 218);
    display: block;
    /* 确保单选框在新的一行 */
}

.strikethrough {
    text-decoration: line-through;
}

.completed-text {
    color: gray;
    /* 勾选的任务变为灰色 */
}



.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #ccc;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  transition: background-color 0.3s, border-color 0.3s;
  cursor: pointer;
}

.active {
  
  border-color: darkgreen; /* 边框颜色变化 */
}

.checkmark {
  color: white; /* 对勾为白色 */
}
</style>